| Conditions | 1 |
| Paths | 1 |
| Total Lines | 161 |
| Code Lines | 104 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | $(window).on('load',function(){
|
||
| 5 | $(document).ready(function() {
|
||
| 6 | //Init side nav |
||
| 7 | $(".button-collapse").sideNav();
|
||
| 8 | $('#modal').modal();
|
||
| 9 | |||
| 10 | //Hide Download Selected Album button |
||
| 11 | $(".selectedAlbums").hide(function() {
|
||
| 12 | $("#profile")
|
||
| 13 | .removeClass("section-profile")
|
||
| 14 | .addClass("profile");
|
||
| 15 | }); |
||
| 16 | |||
| 17 | //================================================================================== |
||
| 18 | $('.card-image').click(function() {
|
||
| 19 | var albumId = $(this).attr('album-id');
|
||
| 20 | $('.loader').css('display','block');
|
||
| 21 | $.ajax({
|
||
| 22 | url: "slider.php?albumId=" + albumId, |
||
| 23 | success: function(result) {
|
||
| 24 | $('.loader').css('display','none');
|
||
| 25 | $('.overlay').css('width','100%');
|
||
| 26 | $('.slideshow-container').html(result);
|
||
| 27 | flag = 1; |
||
| 28 | } |
||
| 29 | }); |
||
| 30 | }) |
||
| 31 | |||
| 32 | //=============== |
||
| 33 | function append_download_link(url) {
|
||
| 34 | $('.download-process').css('display','block');
|
||
| 35 | $('.loadermessage').text("Please wait... Albums are downloading");
|
||
| 36 | $.ajax({
|
||
| 37 | url: url, |
||
| 38 | success: function(result) {
|
||
| 39 | $('.download-process').css('display','none');
|
||
| 40 | $(".modal-content").html(result);
|
||
| 41 | $('#modal').modal('open');
|
||
| 42 | } |
||
| 43 | }); |
||
| 44 | } |
||
| 45 | |||
| 46 | var count = 0; |
||
| 47 | $(".select-album").on("change", function() {
|
||
| 48 | if ($(this).is(":checked")) {
|
||
| 49 | count++; |
||
| 50 | } else {
|
||
| 51 | count--; |
||
| 52 | } |
||
| 53 | if (count > 0) {
|
||
| 54 | $(".selectedAlbums").show(function() {
|
||
| 55 | $("#profile")
|
||
| 56 | .removeClass("profile")
|
||
| 57 | .addClass("section-profile");
|
||
| 58 | }); |
||
| 59 | } else {
|
||
| 60 | $(".selectedAlbums").hide(function() {
|
||
| 61 | $("#profile")
|
||
| 62 | .removeClass("section-profile")
|
||
| 63 | .addClass("profile");
|
||
| 64 | }); |
||
| 65 | } |
||
| 66 | }); |
||
| 67 | |||
| 68 | function get_all_selected_albums() {
|
||
| 69 | var selected_albums; |
||
| 70 | var i = 0; |
||
|
|
|||
| 71 | $(".select-album").each(function() {
|
||
| 72 | if ($(this).is(":checked")) {
|
||
| 73 | if (!selected_albums) {
|
||
| 74 | selected_albums = $(this).val(); |
||
| 75 | } else {
|
||
| 76 | selected_albums = selected_albums + "-" + $(this).val(); |
||
| 77 | } |
||
| 78 | } |
||
| 79 | }); |
||
| 80 | |||
| 81 | return selected_albums; |
||
| 82 | } |
||
| 83 | |||
| 84 | $(".single-export").on("click", function() {
|
||
| 85 | var rel = $(this).attr("rel");
|
||
| 86 | var album = rel.split(",");
|
||
| 87 | append_download_link( |
||
| 88 | "download-album.php?single_export=" + album[0] + "," + album[1] |
||
| 89 | ); |
||
| 90 | }); |
||
| 91 | |||
| 92 | $(".single-download").on("click", function() {
|
||
| 93 | var rel = $(this).attr("rel");
|
||
| 94 | var album = rel.split(",");
|
||
| 95 | append_download_link( |
||
| 96 | "download-album.php?zip=1&single_album=" + album[0] + "," + album[1] |
||
| 97 | ); |
||
| 98 | }); |
||
| 99 | |||
| 100 | $("#download-selected-albums").on("click", function() {
|
||
| 101 | var selected_albums = get_all_selected_albums(); |
||
| 102 | append_download_link( |
||
| 103 | "download-album.php?zip=1&selected_albums=" + selected_albums |
||
| 104 | ); |
||
| 105 | }); |
||
| 106 | |||
| 107 | $(".download-all-albums").on("click", function() {
|
||
| 108 | append_download_link("download-album.php?zip=1&all_albums=all_albums");
|
||
| 109 | }); |
||
| 110 | |||
| 111 | |||
| 112 | function move_to_drive(param1, param2) {
|
||
| 113 | |||
| 114 | var google_access_token = $('.g-access-token').text();
|
||
| 115 | if(google_access_token === "Hello") {
|
||
| 116 | $('.download-process').css('display','block');
|
||
| 117 | $('.loadermessage').text("Please wait... File is moving in to google drive");
|
||
| 118 | $.ajax({
|
||
| 119 | url: "https://localhost:8443/SociaManager/google_drive/google_login.php?" + param1 + "=" + param2, |
||
| 120 | success: function (result) {
|
||
| 121 | $('.download-process').css('display','none');
|
||
| 122 | $(".modal-content").html(result);
|
||
| 123 | $('#modal').modal('open');
|
||
| 124 | } |
||
| 125 | }); |
||
| 126 | } else {
|
||
| 127 | window.location = "https://localhost:8443/SociaManager/google_drive/google_login.php"; |
||
| 128 | } |
||
| 129 | } |
||
| 130 | |||
| 131 | $(".move-single-album").on("click", function() {
|
||
| 132 | var single_album = $(this).attr("rel");
|
||
| 133 | move_to_drive("single_album", single_album);
|
||
| 134 | }); |
||
| 135 | |||
| 136 | $("#move-selected-albums").on("click", function() {
|
||
| 137 | var selected_albums = get_all_selected_albums(); |
||
| 138 | move_to_drive("selected_albums", selected_albums);
|
||
| 139 | }); |
||
| 140 | |||
| 141 | $(".move_all").on("click", function() {
|
||
| 142 | move_to_drive("all_albums", "all_albums");
|
||
| 143 | }); |
||
| 144 | |||
| 145 | $("#uploadimage").on('submit',(function(e) {
|
||
| 146 | e.preventDefault(); |
||
| 147 | $('.download-process').css('display','block');
|
||
| 148 | $('.loadermessage').text("Please wait... Album photo uploading!!");
|
||
| 149 | $.ajax({
|
||
| 150 | url: "ajax_php_file.php", // Url to which the request is send |
||
| 151 | type: "POST", // Type of request to be send, called as method |
||
| 152 | data: new FormData(this), // Data sent to server, a set of key/value pairs (i.e. form fields and values) |
||
| 153 | contentType: false, // The content type used when sending data to the server. |
||
| 154 | cache: false, // To unable request pages to be cached |
||
| 155 | processData:false, // To send DOMDocument or non processed data file it is set to false |
||
| 156 | success: function(data) // A function to be called if request succeeds |
||
| 157 | {
|
||
| 158 | $('.download-process').css('display','none');
|
||
| 159 | $(".modal-content").html(result);
|
||
| 160 | $('#modal').modal('open');
|
||
| 161 | } |
||
| 162 | }); |
||
| 163 | })); |
||
| 164 | |||
| 165 | }); |
||
| 166 | |||
| 209 | } |